<template>
	<view class="page">
		<view class="infoBox">
			<view class="row">
				<view class="lable">
					姓名:
				</view>
				<view class="value">
					{{form.memberName}}
				</view>
			</view>
			<view class="row">
				<view class="lable">
					学号:
				</view>
				<view class="value">
					{{form.memberNo}}
				</view>
			</view>
			<view class="row">
				<view class="lable">
					班级:
				</view>
				<view class="value">
					{{form.subsidiaryName}}
				</view>
			</view>
			<view class="row">
				<view class="lable">
					注册状态:
				</view>
				<view class="value">
					{{ isRegister ? '已注册' : '未注册'}}
				</view>
			</view>
		</view>
		
		<image class="image" :src="image"   mode=""></image>
		
		<view class="btn" @click="takeImage">
			相机拍照
		</view>
		<view class="tips">
			 [ 请将人脸置于镜头中间，注意光线均匀 ]
		</view>
	</view>
</template>

<script>
	import {getfeatureImgApi,} from '@/common/api/commonApi/commonApi.js'
	export default {
		data() {
			return {
				image : '',
				count : 0,
				isRegister : false,
				form: {
					memberName : '',
					memberNo : '',
					subsidiaryName : ''
				},
				
			}
		},
		methods: {
			takeImage(){
				this.count = 0
				this.goPage('/pages/componentsB/faceEntry/faceEntry')
			},
			postInfo(){
				let formData = {
					memberId : this.form.id
				} 
				this.uploadFile('/SmartPortal/portal/registerdata',this.image,formData,'file').then(res=>{
					let data = JSON.parse(res.data)
					console.log(data);
					if(data.code == '00'){
						this.setMessage('上传成功')
						this.getImageInfo()
					}else{
						this.setMessage('上传失败，请重新拍照上传！')
					}
					console.log(data);
				})
			},
			getImageInfo(){
				getfeatureImgApi().then(res=>{
					if(res.imagebase64){
						this.image = res.imagebase64.replace(/[\r\n]/g,"")
						this.isRegister = true
						console.log(this.image);
					}
				})
			}
		},
		onLoad() {
			this.form = uni.getStorageSync('selectInfoAccount')
			this.getImageInfo()
		},
		onShow() {
			uni.$on('validimgEmit',(res)=>{
				if(this.count > 0) return
				this.count++
				this.image = res.image
				this.postInfo()
			})
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #fff;
	height: 100vh;
	.infoBox{
		height: 380rpx;
		padding: 100rpx 70rpx 0;
		.row{
			&:nth-child(1){
				font-size: 34rpx;
				color: #000;
			}
			display: flex;
			justify-content: space-between;
			margin-bottom: 40rpx;
			.label{
				
			}
			.value{
				
			}
		}
	}
	.image{
		width: 420rpx;
		height: 420rpx;
		margin: 50rpx auto;
		// background-color: #4089f0;
	}
	.btn{
		color: #fff;
		background-color: #0acaa2;
		width: 310rpx;
		height: 90rpx;
		margin: auto;
		border-radius: 10rpx;
		@include flexCenter;
	}
	.tips{
		margin:20rpx  auto;
		@include flexCenter;
	}
}
</style>
